package com.study.system.user.controller;

import com.edu.common.util.OssUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class UploadController {

    @RequestMapping("/upload")
    public ResponseEntity<String> upload(MultipartFile file) throws IOException {
        //上传到oss
        OssUtils.upload(file.getInputStream(),file.getOriginalFilename());
        //返回文件完整的路径
        return ResponseEntity.ok(OssUtils.getURL(file.getOriginalFilename()));
    }
}
